import {reqAddressInfo, reqOrderInfo} from '@/api'
const state = {
    address:[],
    orderInfo:{}
};
//mutations:修改state的唯一手段
const mutations = {
    GETUSERADDRESS(state, address){
        state.address = address
    },
    GETORDER(state, orderInfo){
        state.orderInfo = orderInfo
    }
};
//action:处理action, 可以书写自己的业务逻辑，也可以处理异步
const actions = {
    //获取用户地址信息
    async getUserAddress({commit}){
        let result =   await reqAddressInfo()
        if(result.code==200){
            commit('GETUSERADDRESS', result.data)
        }
    },
    //获取商品清单的数据
    async getOrder({commit}){
        let result =   await reqOrderInfo()
        if(result.code==200){
            commit('GETORDER', result.data)
        }
    }

};
const getters = {

};

//对外暴露Store类的一个实例
export default {
    state,
    mutations,
    actions,
    getters
}